<template>

  <div id="app">
    <transition :name="transitionName">
      <router-view class="child-view" />
    </transition>

    <van-tabbar v-model="active" v-show="show" placeholder=true>
      <van-tabbar-item icon="home-o" to="/main">鲶鱼
        <!--        <router-link to="/main">home</router-link>-->
      </van-tabbar-item>
      <van-tabbar-item icon="add-o" size="20px" to="/shangpinfabu">发布
        <!--        <router-link to="/shangpinfabu">new</router-link>-->
      </van-tabbar-item>
      <van-tabbar-item icon="chat-o" to="/c">消息
        <!--        <router-link to="/shangpinfabu">new</router-link>-->
      </van-tabbar-item>
      <van-tabbar-item icon="user-circle-o" to="/gerenzhuye">我的
        <!--        <router-link to="/gerenzhuye">me</router-link>-->
      </van-tabbar-item>
    </van-tabbar>
  </div>

</template>

<script>
export default {
  name: "App",
  components: {},
  data() {
    return {
      active: '0',
      transitionName: '',
      show: true,
    }
  },
  watch: {
    '$route'(to, from) {

      if (from.path === '/' || from.path === "/myfabu" || from.path === '/main' || from.path === '/sousuo' || from.path === '/shangpinfabu' || from.path === '/gerenzhuye' || from.path === '/goodsdetail' || from.path === '/ordersubmit') {
        if (to.path === '/login' || to.path === '/' || to.path === '/main' || to.path === '/sousuo' || to.path === '/shangpinfabu' || to.path === '/gerenzhuye' || to.path === '/goodsdetail' || to.path === '/orderTotal') {

          if (to.path === '/goodsdetail') {
            this.show = false;
            this.transitionName = 'slide-right';
          } else {
            this.show = true;
            this.transitionName = 'slide-right';
          }

        } else {

          this.transitionName = 'slide-left';
        }
      }
    }
  }
};
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

.router-link {
  text-decoration: none;
}

.child-view {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transition: all .5s cubic-bezier(.55, 0, .1, 1);
}

.slide-left-enter,
.slide-right-leave-active {
  opacity: 0;
  -webkit-transform: translate(30px, 0);
  transform: translate(30px, 0);
}

.slide-left-leave-active,
.slide-right-enter {
  opacity: 0;
  -webkit-transform: translate(-30px, 0);
  transform: translate(-30px, 0);
}
</style>